package com.ukao.cashregister.ui.setting;


import android.os.Build;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.ukao.cashregister.R;
import com.ukao.cashregister.base.BaseFragment;
import com.ukao.cashregister.consts.SaveParamets;
import com.ukao.cashregister.utils.AppUtils;
import com.ukao.cashregister.utils.CheckUtils;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;

/**
 * 关于本机
 */
public class AboutLocalFragment extends BaseFragment {

    private static final String ARG_PARAM1 = "param1";
    private static final String ARG_PARAM2 = "param2";
    @BindView(R.id.textView5)
    TextView textView5;
    @BindView(R.id.system)
    TextView system;
    @BindView(R.id.model)
    TextView model;
    @BindView(R.id.versions)
    TextView versions;

    Unbinder unbinder;
    @BindView(R.id.wife_ip)
    TextView wifeIp;
    @BindView(R.id.wired_txt)
    TextView wiredTxt;
    @BindView(R.id.cpu_txt)
    TextView cpuTxt;
    @BindView(R.id.total_ram)
    TextView totalRam;
    @BindView(R.id.storage_space)
    TextView storageSpace;
    @BindView(R.id.wi_fi_name)
    TextView wiFiName;
    @BindView(R.id.rfid_txt)
    TextView rfidTxt;
    @BindView(R.id.touch_screen)
    TextView touchScreen;
    @BindView(R.id.serial_number)
    TextView serialNumber;
    @BindView(R.id.liquid_crystal)
    TextView liquidCrystal;
    private  int  i;
    // TODO: Rename and change types of parameters
    private String mParam1;
    private String mParam2;


    public static AboutLocalFragment newInstance(String param1, String param2) {
        AboutLocalFragment fragment = new AboutLocalFragment();
        Bundle args = new Bundle();
        args.putString(ARG_PARAM1, param1);
        args.putString(ARG_PARAM2, param2);
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (getArguments() != null) {
            mParam1 = getArguments().getString(ARG_PARAM1);
            mParam2 = getArguments().getString(ARG_PARAM2);
        }
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {

        View view = inflater.inflate(R.layout.fragment_about_local, container, false);
        unbinder = ButterKnife.bind(this, view);
        initView();
        return view;
    }


    @Override
    protected void initView() {
        i=0;
        serialNumber.setText(SaveParamets.getCode());
        model.setText(Build.MODEL);/*型号*/
        versions.setText(resources.getString(R.string.app_name)+ AppUtils.getVersionName(_mActivity));
        wifeIp.setText(AppUtils.getWirelseeIp());
        wiredTxt.setText(AppUtils.getLocalIp());
        cpuTxt.setText(CheckUtils.isEmptyString(Build.CPU_ABI));
        totalRam.setText(CheckUtils.isEmptyString(AppUtils.getTotalRam()));
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
            storageSpace.setText(AppUtils.getInternalMemorySize(_mActivity));
        }


    }

    @Override
    public void onSupportVisible() {
        super.onSupportVisible();
        wiredTxt.setText(CheckUtils.isEmptyString(AppUtils.getWIfiName(_mActivity)));
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }

    @OnClick(R.id.textView5)
    public void onViewClicked() {
//        i++;
//        if (i>2){
//            loadUpgradeInfo();
//        }


    }



}
